<include file="Common:header" />
<body>
<!--面包屑导航 开始-->
<div class="crumb_warp">
    <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
    <i class="fa fa-home"></i> <a href="{:U(MODULE_NAME.'/Index/info')}">首页</a> &raquo; 模块管理
</div>
<!--面包屑导航 结束-->
<form action="{:U(MODULE_NAME.'/Access/setAccess')}" method="post">
<div id='warp' class=add-app>
    <foreach name='node' item='app'>
        <div class="app">
            <p id="app">
                <strong>{$app.title}</strong>
                <!-- {$app.id}_1  节点id_节点等级id -->
                <input type="checkbox" name="access[]" value="{$app.id}_1"
                       level="1"
                <if condition="$app['access']">checked="checked"</if>
                />
            </p>
            <foreach name='app.child' item='action'>
                <dl>
                    <dt id="action">
                        <strong>{$action.title}</strong> <input type="checkbox" name="access[]" value="{$action.id}_2" level="2"
                        <if condition="$action['access']">checked="checked"</if>
                        />
                    </dt>
                    <foreach name='action.child' item='child'>
                        <dd id="child">
                            <span>{$child.title}</span> <input type="checkbox" name="access[]"
                                                               value="{$child.id}_3" level="3"
                            <if condition="$child['access']">checked="checked"</if>
                            />
                        </dd>
                    </foreach>
                </dl>
            </foreach>
        </div>
    </foreach>
</div>
    <div style="text-align:center">
        <input type="hidden" name="rid" value="{$rid}"> <input type="submit" value="提交">
        <input type="button" class="back" onclick="history.go(-1)" value="返回">
    </div>
</form>
</body>
</html>
<script>
    $(function() {
        $('input[level=1]').click(
                function() {
                    //.parents 查找节点
                    var inputs = $(this).parents('.app').find('input');
                    $(this).attr('checked') ? inputs.attr('checked', 'chedked')
                            : inputs.removeAttr('checked');
                });
        $('input[level=2]').click(
                function() {
                    var inputs = $(this).parents('dl').find('input');
                    $(this).attr('checked') ? inputs.attr('checked', 'chedked')
                            : inputs.removeAttr('checked');
                });
    });
</script>